package coreGobalEx;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GobalEx {

	public static final String DEFAULT_ERROR_VIEW = "error";
	@ExceptionHandler()
	public ModelAndView defaultError(HttpServletRequest request, Exception ex){
		ModelAndView mav = new ModelAndView();
		mav.addObject("exception" , ex);
		mav.addObject("url",request.getRequestURL());
		mav.setViewName(DEFAULT_ERROR_VIEW);
		return mav;
	}
}
